package cn.itcast.mapper;

import cn.itcast.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface ISetmealDishMapper {
    @Insert("insert into setmeal_dish values(null,#{setmealId},#{dishId},#{name},#{price}" +
            ",#{copies},0,#{createTime},#{updateTime},#{createUser},#{updateUser},0)")
    void save(SetmealDish setmealDish);


    @Select("select * from setmeal_dish where setmeal_id =#{setmealId}")
    List<SetmealDish> findBySetmealId(Long setmealId);


    void deleteWithSetmealId(@Param("ids") Long[] ids);

    @Select("SELECT * FROM setmeal_dish s INNER JOIN dish d ON s.dish_id = d.id WHERE setmeal_id = #{setmealId}")
    List<Map<String,Object>> findSetmealDish(Long setmealId);
}
